home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 43
/
043.d81
/
sliding checkers
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
114 lines
10 at=679:fori=at to at+22:readx:pokei,x:next:print"[147]":as=3
20 data32,180,2,132,251,32,180,2
30 data166,251,76,240,255,32,253,174
40 goto610
50 le=len(a$):e=(20+le/2):for a=1 to le:
55 b$=mid$(a$,le+1-a,1):printb$;
60 for b=1 to e:print"[157] "b$;
65 next:print:print"[145]";
70 e=e-1:next
80 return
100 data32,158,173,32,170,177,96
110 pokevo,15:pokewv,17:pokeak,15:pokehi,58:pokelo,149
120 fortm=1to100:nexttm:pokewv,0
130 pokewv,17:pokehi,34:pokelo,75:fortm=1to100:nexttm:pokewv,0:return
140 rem - setup screen
150 sys at,1,12:print"sliding checkers[146]";
160 er=0:fr$="":ct=fre(0)
170 sys at,9,8:print"[159]1[146] 2[146] 3[146] 4[146] 5[146] 6[146] 7[146] 8[146] 9[146]";
180 sys at,11,7:printa$(b(1))u$a$(b(2))u$a$(b(3))u$a$(b(4));
190 sys at,11,19:printa$(b(5))u$a$(b(6))u$a$(b(7))u$a$(b(8))u$a$(b(9))
200 if f2$="*" then gosub110
210 sys at,18,15:print"[154]move #";
220 if as=3 then 815
230 if d$=e$ then er=3:goto480
240 if as<>1 then270
250 zz=zz+1:fr$=mid$(slv$,zz,1):sys at,15,24:printfr$;
260 for tm=1to750:next:goto330
270 print:print"[145][145][145] [154](f1 [154]- auto solve ... f7 [154]- end)"
275 sys at,15,12:print"[154]enter move: [157]";:poke198,0
280 get fr$
290 for i=1to11:iffr$=mid$("[133][136]123456789",i,1)thenprintfr$;:goto310
300 next:goto280
310 if fr$="[133]" then as=1:sys at,3,14:print"auto solving":goto700
320 if fr$="[136]" then er=5:as=2:goto480:rem - end
330 fr=val(fr$):if c(fr)=3 thener=1:goto480
340 for x=1to9:ifmid$(d$,x,1)="3" then tu=x
350 next
360 rem - check for legal move
370 if abs(fr-tu)>2 then er=2:goto480
380 if abs(fr-tu)=2 then if fr<tu then if c(fr)=c(fr+1) then er=2:goto480
390 if abs(fr-tu)=2 then if fr>tu then if c(fr)=c(fr-1) then er=2:goto480
400 if c(fr)=1 then if fr>tu then er=2:goto480
410 if c(fr)=2 then if fr<tu then er=2:goto480
420 rem - switch pieces
430 c=c(tu):c(tu)=c(fr):c(fr)=c
440 d$="":forx=1to9:d$=d$+right$(str$(c(x)),1):next
450 forx=1to9:b(x)=c(x):next:f2$="*"
460 mv=mv+1:mv$="":mv$=str$(mv):sys at,18,22:print mv$;:goto150
470 rem - msg rtn
480 if as=1 then er=4
490 b1=490+(er*10):poke785,188:poke786,168:pokeb1,peek(b1):b1=usr(0)
500 er$="[150]'from[150]' position empty[146]":goto550
510 er$="[150]invalid entry[146]":goto550
520 er$="[154]congratulations!![146]":goto550
530 er$="[154]puzzle solved![146]":goto550
540 er$="[154]thanks for playing![146]"
550 c=(22-len(er$)/2):forx=1to5:sys at,24,c:printer$;:fortm=1to100:nexttm
560 poke781,24:sys59903:fortm=1to100:nexttm,x
570 er$="":f2$="":if er<3 then150
580 if as<>2 then590
581 run
590 er=5:as=2:goto490
600 rem - initialization
610 dim a$(3),b(9),c(9):poke53280,.
620 u$="[145][145]"
630 a$(1)=" [157][157][157] [146][154][209] [157][157][157] [146]"
640 a$(2)=" [157][157][157] [146][209] [157][157][157] [146]"
650 a$(3)=" [157][157][157] [158] [157][157][157] [146]"
660 e$="222231111":rem - solution format
670 rem - sound parameters
680 vo=54296:wv=54276:ak=54277:hi=54273:lo=54272
690 rem - autosolve mode
700 d$="111132222":rem - puzzle format
710 forx=1to9:b(x)=val(mid$(d$,x,1)):c(x)=b(x):next
720 if as=3 then 1000
730 mv=0:zz=0:f2$="":sys at,18,22:print" ";
740 rem - solution string
750 slv$="467532468975312468753465"
760 print"";:goto150
770 rem - introduction
780 printchr$(142)"[147]":poke53281,0:sys at,1,12:print"sliding checkers[146]":print
790 print" four blue and four white checkers"
800 print" are arranged as follows:"
810 as=3:goto150
815 print:print" [154]press space[146][154] to continue":poke198,.
816 ifpeek(203)<>60then816
820 print"[147]":sys at,1,12:print"sliding checkers[146]":print
830 print" [154]reverse the positions of the checkers.":print
840 print" blue checkers move only to the":print" right; white checkers to ";
850 print"the left.":print
860 print" you may move to an empty space or"
870 print" jump over an opposite checker.":print
880 print" press f1[154] for auto-solve; f7[154]":print" to end.":print
890 print" this puzzle can be solved in 24":print" moves."
900 sys at,22,8:print"press space[146][154] to continue":poke198,.
910 get rt$:if rt$<>" " then910
920 as=0:f2$="":print"[147]":goto1000
1000 poke53280,.:poke53281,.:printchr$(142)"[147]"
1005 a$="s l i d i n g c h e c k e r s":gosub50:print
1010 print"[158]":a$="by daniel miller":gosub50
1015 print" i [154]- instructions"
1020 print" p [154]- play sliding checkers"
1030 print" q [154]- quit"
1040 print" press p [154]or q[154]."
1050 a=peek(203):ifa<>33anda<>41anda<>62then1050
1060 ifa=41thenprint"[147]":as=.:goto150
1070 ifa=33then780
60000 print"[145] [154]are you sure you want to quit? (y[154]/n[154])"
60010 a=peek(203):ifa<>25anda<>39then60010
60020 ifa=39thenprint"[145] [145]":goto1040
60030 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
60040 ifer<>63thenend
60050 load"hello connect",8